/********************************************************************************
  * @Copyright: Metanergy Technology R&D Co., Ltd
  * @filename: myg0025_syscfg.h
  * @brief: SYSCFG Initialization and Configuration functions
  * @Author: AE Team
  * @version: V1.0.0/2022-05-24
*********************************************************************************/

/*!< Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MYG0025_SYSCFG_H
#define __MYG0025_SYSCFG_H

#ifdef __cplusplus
extern "C" {
#endif

/*!< Includes ------------------------------------------------------------------*/
#include "myg0025.h"

/** @addtogroup SYSCFG SYSCFG
  * @{
  */

/** @defgroup SYSCFG_Exported_Constants SYSCFG_Exported_Constants
  * @{
  */

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

/** @defgroup SYSCFG_EXTI_Port_Sources SYSCFG_EXTI_Port_Sources
  * @{
  */
#define EXTI_PortSourceGPIOA       ((uint8_t)0x00)
#define EXTI_PortSourceGPIOB       ((uint8_t)0x01)
#define EXTI_PortSourceGPIOC       ((uint8_t)0x02)
#define EXTI_PortSourceGPIOF       ((uint8_t)0x05)

#define IS_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == EXTI_PortSourceGPIOA) || \
                                         ((PORTSOURCE) == EXTI_PortSourceGPIOB) || \
                                         ((PORTSOURCE) == EXTI_PortSourceGPIOC) || \
                                         ((PORTSOURCE) == EXTI_PortSourceGPIOF))
/**
  * @}
  */

/** @defgroup SYSCFG_EXTI_Pin_sources SYSCFG_EXTI_Pin_sources
  * @{
  */
#define EXTI_PinSource0            ((uint8_t)0x00)
#define EXTI_PinSource1            ((uint8_t)0x01)
#define EXTI_PinSource2            ((uint8_t)0x02)
#define EXTI_PinSource3            ((uint8_t)0x03)
#define EXTI_PinSource4            ((uint8_t)0x04)
#define EXTI_PinSource5            ((uint8_t)0x05)
#define EXTI_PinSource6            ((uint8_t)0x06)
#define EXTI_PinSource7            ((uint8_t)0x07)
#define EXTI_PinSource8            ((uint8_t)0x08)
#define EXTI_PinSource9            ((uint8_t)0x09)
#define EXTI_PinSource10           ((uint8_t)0x0A)
#define EXTI_PinSource11           ((uint8_t)0x0B)
#define EXTI_PinSource12           ((uint8_t)0x0C)
#define EXTI_PinSource13           ((uint8_t)0x0D)
#define EXTI_PinSource14           ((uint8_t)0x0E)
#define EXTI_PinSource15           ((uint8_t)0x0F)

#define IS_EXTI_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == EXTI_PinSource0) || \
                                       ((PINSOURCE) == EXTI_PinSource1) || \
                                       ((PINSOURCE) == EXTI_PinSource2) || \
                                       ((PINSOURCE) == EXTI_PinSource3) || \
                                       ((PINSOURCE) == EXTI_PinSource4) || \
                                       ((PINSOURCE) == EXTI_PinSource5) || \
                                       ((PINSOURCE) == EXTI_PinSource6) || \
                                       ((PINSOURCE) == EXTI_PinSource7) || \
                                       ((PINSOURCE) == EXTI_PinSource8) || \
                                       ((PINSOURCE) == EXTI_PinSource9) || \
                                       ((PINSOURCE) == EXTI_PinSource10) || \
                                       ((PINSOURCE) == EXTI_PinSource11) || \
                                       ((PINSOURCE) == EXTI_PinSource12) || \
                                       ((PINSOURCE) == EXTI_PinSource13) || \
                                       ((PINSOURCE) == EXTI_PinSource14) || \
                                       ((PINSOURCE) == EXTI_PinSource15))
/**
  * @}
  */

/** @defgroup SYSCFG_Memory_Remap_Config SYSCFG_Memory_Remap_Config
  * @{
  */
#define SYSCFG_MemoryRemap_Flash                ((uint8_t)0x00)
#define SYSCFG_MemoryRemap_SystemMemory         ((uint8_t)0x01)
#define SYSCFG_MemoryRemap_SRAM                 ((uint8_t)0x03)


#define IS_SYSCFG_MEMORY_REMAP(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \
                                       ((REMAP) == SYSCFG_MemoryRemap_SystemMemory) || \
                                       ((REMAP) == SYSCFG_MemoryRemap_SRAM))

/**
  * @}
  */

/** @defgroup SYSCFG_SYSCFG_CTX_RTX_Remap_Config SYSCFG_SYSCFG_CTX_RTX_Remap_Config
  * @{
  */
#define UART1_CTS_RTS_RMP   SYSCFG_CFGR1_UART1_CTS_RTS_RMP
#define UART2_CTS_RTS_RMP   SYSCFG_CFGR1_UART2_CTS_RTS_RMP

#define IS_SYSCFG_CTX_RTX_Remap_CONFIG(REMAP) (((REMAP) == UART1_CTS_RTS_RMP) || \
                                               ((REMAP) == UART2_CTS_RTS_RMP))

/**
  * @}
  */

/** @defgroup SYSCFG_I2C_FastModePlus_Config SYSCFG_I2C_FastModePlus_Config
  * @{
  */
#define SYSCFG_I2CFastModePlus_PC6      SYSCFG_CFGR1_I2C1_PC6_FMP /* Enable Fast Mode Plus on PC6 */
#define SYSCFG_I2CFastModePlus_PC5      SYSCFG_CFGR1_I2C1_PC5_FMP /* Enable Fast Mode Plus on PC5 */
#define SYSCFG_I2CFastModePlus_PB15     SYSCFG_CFGR1_I2C1_PB15_FMP /* Enable Fast Mode Plus on PB15 */
#define SYSCFG_I2CFastModePlus_PB12     SYSCFG_CFGR1_I2C1_PB12_FMP /* Enable Fast Mode Plus on PB12 */

#define IS_SYSCFG_I2C_FMP(PIN) (((PIN) == SYSCFG_I2CFastModePlus_PC6 )  || \
                                ((PIN) == SYSCFG_I2CFastModePlus_PC5 )  || \
                                ((PIN) == SYSCFG_I2CFastModePlus_PB15)  || \
                                ((PIN) == SYSCFG_I2CFastModePlus_PB12))


/**
  * @}
  */


/** @defgroup SYSCFG_Vref_Sel_Config SYSCFG_Vref_Sel_Config
  * @{
  */

#define SYSCFG_Vref_Sel_VDDH                ((uint32_t)0x00000000)
#define SYSCFG_Vref_Sel_VREF12              ((uint32_t)0x40000000)

#define IS_SYSCFG_Vref_Sel(SEL) (((SEL) == SYSCFG_Vref_Sel_VDDH)||\
                                 ((SEL) == SYSCFG_Vref_Sel_VREF12))

/**
  * @}
  */

/** @defgroup SYSCFG_DIV_VOUT_Buf_EN_Config SYSCFG_DIV_VOUT_Buf_EN_Config
  * @{
  */

#define SYSCFG_DIV_VOUT_Buf_EN               SYSCFG_CFGR3_EN_BUF_DIV_VOUT
#define SYSCFG_DIV_VOUT_Buf_DISABLE          ((uint32_t)0x00000000)

#define IS_SYSCFG_DIV_VOUT_Buf(Buf) (((Buf) == SYSCFG_DIV_VOUT_Buf_EN)||\
                                                                 ((Buf) == SYSCFG_DIV_VOUT_Buf_DISABLE))

/**
  * @}
  */

/** @defgroup SYSCFG_SW_VREF12_PC4_EN_Config SYSCFG_SW_VREF12_PC4_EN_Config
  * @{
  */

#define SYSCFG_SW_VREF12_PC4_EN               SYSCFG_CFGR3_EN_SW_VREF12_PC4
#define SYSCFG_SW_VREF12_PC4_DISABLE          ((uint32_t)0x00000000)

#define IS_SYSCFG_SW_VREF12_PC4(Buf) (((Buf) == SYSCFG_SW_VREF12_PC4_EN)||\
                                      ((Buf) == SYSCFG_SW_VREF12_PC4_DISABLE))

/**
  * @}
  */

/** @defgroup SYSCFG_SW_VOLTAGE_DIV_PA5_EN_Config SYSCFG_SW_VOLTAGE_DIV_PA5_EN_Config
  * @{
  */

#define SYSCFG_SW_VOLTAGE_DIV_PA5_EN               SYSCFG_CFGR3_EN_SW_VOLTAGE_DIV_PA5
#define SYSCFG_SW_VOLTAGE_DIV_PA5_DISABLE          ((uint32_t)0x00000000)

#define IS_SYSCFG_SW_VOLTAGE_DIV_PA5(Buf) (((Buf) == SYSCFG_SW_VOLTAGE_DIV_PA5_EN)||\
                                           ((Buf) == SYSCFG_SW_VOLTAGE_DIV_PA5_DISABLE))

/**
  * @}
  */

/** @defgroup SYSCFG_SW_VIN_LVD_PA8_EN_Config SYSCFG_SW_VIN_LVD_PA8_EN_Config
  * @{
  */

#define SYSCFG_SW_VIN_LVD_PA8_EN               SYSCFG_CFGR3_EN_SW_VIN_LVD
#define SYSCFG_SW_VIN_LVD_PA8_DISABLE          ((uint32_t)0x00000000)

#define IS_SYSCFG_SW_VIN_LVD_PA8(Buf) (((Buf) == SYSCFG_SW_VIN_LVD_PA8_EN)||\
                                                                 ((Buf) == SYSCFG_SW_VIN_LVD_PA8_DISABLE))

/**
  * @}
  */

/** @defgroup SYSCFG_VOLTAGE_DIV_EN_Config SYSCFG_VOLTAGE_DIV_EN_Config
  * @{
  */

#define SYSCFG_VOLTAGE_DIV_EN               SYSCFG_CFGR3_VOLTAGE_DIV_EN
#define SYSCFG_VOLTAGE_DIV_DISABLE          ((uint32_t)0x00000000)

#define IS_SYSCFG_VOLTAGE_DIV_EN(Buf) (((Buf) == SYSCFG_VOLTAGE_DIV_EN)||\
                                                                 ((Buf) == SYSCFG_VOLTAGE_DIV_DISABLE))

/**
  * @}
  */

/** @defgroup SYSCFG_VOLTAGE_DIV_DATA_Config SYSCFG_VOLTAGE_DIV_DATA_Config
  * @{
  */

#define IS_SYSCFG_VOLTAGE_DIV_DATA(VOLTAGE_DIV_DATA) ((VOLTAGE_DIV_DATA) <= 0xFF)

/**
  * @}
  */

/** @defgroup SYSCFG_REF_LOCK_Config SYSCFG_REF_LOCK_Config
  * @{
  */

#define SYSCFG_REF_LOCK            SYSCFG_CFGR3_REF_LOCK
#define SYSCFG_REF_UNLOCK          ((uint32_t)0x00000000)

#define IS_SYSCFG_REF_LOCK_CONFIG(Buf) (((Buf) == SYSCFG_REF_LOCK)||\
                                                                 ((Buf) == SYSCFG_REF_UNLOCK))

/**
  * @}
  */

/** @defgroup SYSCFG_TIM3_CH4_Remap_Config SYSCFG_TIM3_CH4_Remap_Config
  * @{
  */
#define SYSCFG_TIM3_CH4_Remap_0               ((uint32_t)0x00000000)
#define SYSCFG_TIM3_CH4_Remap_1               ((uint32_t)0x00010000)
#define SYSCFG_TIM3_CH4_Remap_2               ((uint32_t)0x00020000)
#define SYSCFG_TIM3_CH4_Remap_3               ((uint32_t)0x00030000)
#define SYSCFG_TIM3_CH4_Remap_4               ((uint32_t)0x00040000)
#define SYSCFG_TIM3_CH4_Remap_5               ((uint32_t)0x00050000)
#define SYSCFG_TIM3_CH4_Remap_6               ((uint32_t)0x00060000)
#define SYSCFG_TIM3_CH4_Remap_7               ((uint32_t)0x00070000)

#define IS_SYSCFG_TIM3_CH4_Remap(REMAP) (((REMAP) == SYSCFG_TIM3_CH4_Remap_0) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_1) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_2) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_3) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_4) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_5) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_6) || \
                                                                                 ((REMAP) == SYSCFG_TIM3_CH4_Remap_7))

/**
  * @}
  */


/**
  * @}
  */


/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

/** @defgroup SYSCFG_Exported_Functions SYSCFG_Exported_Functions
  * @{
  */

/*  Function used to set the SYSCFG configuration to the default reset state **/
void SYSCFG_DeInit(void);

/* SYSCFG configuration functions *********************************************/
void SYSCFG_MemoryRemapConfig(uint32_t SYSCFG_MemoryRemap);
void SYSCFG_I2CFastModePlusConfig(uint32_t SYSCFG_I2CFastModePlus, FunctionalState NewState);
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex);
void SYSCFG_BreakConfig(uint32_t SYSCFG_Break, FunctionalState NewStaus);
void SYSCFG_TIM3_CH4_REMAP_Config(uint32_t SYSCFG_TIM3_CH4_REMAP);
void SYSCFG_UART_CTX_RTX_Remap_Config(uint32_t SYSCFG_CTX_RTX_Remap, FunctionalState NewStaus);
void SYSCFG_SW_VREF12_PC4_EN_CMD(uint32_t SYSCFG_SW_VREF12_PC4);
void SYSCFG_SW_VOLTAGE_DIV_PA5_EN_CMD(uint32_t SYSCFG_SW_VOLTAGE_DIV_PA5);
void SYSCFG_SW_VTEST_PA8_EN_CMD(uint32_t SYSCFG_SW_VTEST_PA8);
void SYSCFG_SW_VIN_LVD_PA8_EN_CMD(uint32_t SYSCFG_SW_VIN_LVD_PA8);
void SYSCFG_VOLTAGE_DIV_EN_CMD(uint32_t SYSCFG_VOLTAGE_DIV);
void SYSCFG_VOLTAGE_DIV_DATA_Config(uint8_t VOLTAGE_DIV_DATA);
void SYSCFG_REF_LOCK_Config(uint32_t REF_LOCK);


/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /*__MYG0025_SYSCFG_H */
